package com.code.zjm.demo.ui;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {
    private ArrayAdapter<ListCellData> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
        setListAdapter(adapter);
        adapter.add(new ListCellData(this, "RadioGroup", new Intent(this, AtyShowRadioGroup.class)));
        adapter.add(new ListCellData(this, "DatePicker", new Intent(this, AtyShowDatePicker.class)));
        adapter.add(new ListCellData(this, "Spinner", new Intent(this, AtyShowSpinner.class)));
        adapter.add(new ListCellData(this, "Notification", new Intent(this, AtyShowNotification.class)));
        adapter.add(new ListCellData(this, "Gallery", new Intent(this, AtyShowGallery.class)));
        adapter.add(new ListCellData(this, "NeonEffect", new Intent(this, AtyShowNeonEffect.class)));


    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        ListCellData data = adapter.getItem(position);
        if (data != null) {
            data.startActivity();
        }
    }
}
